Skip to content

fix: in VSCode, correctly resolve relative paths to errors - #13367

Merged
bors merged 1 commit into
rust-lang:masterfrom
matklad:fix-problem-matchers
Oct 10, 2022
Merged

bors merged 1 commit into
rust-lang:masterfrom
matklad:fix-problem-matchers

Conversation

@matklad

@matklad matklad commented Oct 8, 2022

Copy link
Copy Markdown
Contributor

VS Code problem matcher are restricted to be static "regexes". You can't create a problem matcher dynamically, and you can't use custom code in lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths relative to the root of the Cargo workspace, but VS Code doesn't necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like this:

"fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace root. VS Code allows to specify a command inside ${}. So we can plug custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!

VS Code problem matcher are restricted to be static "regexes". You can't
create a problem matcher dynamically, and you can't use custom code in
lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths
relative to the root of the Cargo workspace, but VS Code doesn't
necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like
this:

    "fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace
root. VS Code allows to specify a command inside `${}`. So we can plug
custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!
@Veykril

Veykril commented Oct 10, 2022

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

📌 Commit 5bbfea0 has been approved by Veykril

It is now in the queue for this repository.

@bors

bors commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit 5bbfea0 with merge 79a3f84...

@bors

bors commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 79a3f84 to master...

@bors
bors merged commit 79a3f84 into rust-lang:master Oct 10, 2022
@matklad
matklad deleted the fix-problem-matchers branch October 10, 2022 08:10
bors added a commit that referenced this pull request Oct 14, 2022
…=jonas-schievink

Revert "fix: in VSCode, correctly resolve relative paths to errors"

Reverts #13367

I didn't manage to figure out what exactly is the issue, so reverting this to fix #13404 before monday.
@Sytten

Sytten commented Oct 14, 2022

Copy link
Copy Markdown

@matklad The PR was reverted FYI because it broke the test button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants